package org.example.observe.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.example.observe.service.OrderEvent;
import org.example.observe.service.OrderObserve;
import org.example.observe.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.Observable;
import java.util.Observer;

/**
 * 积分业务:给用户新增积分
 */
@Slf4j
@Service
public class CreditServiceImpl implements
        OrderObserve,// 自定义方式
        ApplicationListener<OrderEvent> {// Spring方式

    @Override
    public void paySuccess(String orderNo) {
        log.info("积分业务:给用户新增积分,{}",orderNo);
    }

    @Override
    public void onApplicationEvent(OrderEvent event) {
        log.info("积分业务:给用户新增积分,{}",event.getSource());
    }
}
